using System;
using System.Collections.Generic;
using System.Linq;
using contracts.generation;
using data.contracts;
using generator.Properties;

namespace generator
{
    public class Generator : IGenerator
    {
        public void Process(IEnumerable<Board> boards) {
            Result(Generate(boards));
        }

        private static string Generate(IEnumerable<Board> boards) {
            return Resources.FileTemplate
                .Replace("$boards$", GenerateBoards(boards));
        }

        private static string GenerateBoards(IEnumerable<Board> boards) {
            return boards.Aggregate("", (current, board) => current + BoardGenerator.Generate(board));
        }

        public event Action<string> Result;
    }
}